<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			//和电脑玩一个剪刀石头布的游戏，电脑随机出，用户输入剪刀、石头或者布，判断谁赢随机数可以参考Math.random()方法。
			var player = window.prompt("请输入石头或剪刀或布");
			document.write("你出的是:" + player);
			var arr = ["剪刀", "石头", "布"];
			console.log(arr[0]);
			var computer = (parseInt(Math.random(0, 2) * 3));
			if (computer == 0) {
				computer = arr[0];
			} else if (computer == 1) {
				computer = arr[1];
			} else if (computer == 2) {
				computer = arr[2];
			}
			document.write("<br />");
			document.write("电脑出的是:" + computer);
			document.write("<br />");
			if(player == '石头' && computer == arr[0] || player == '剪刀' && computer == arr[2] || player == '布' && computer == arr[1])	{
				document.write("恭喜你，你赢了");
			}else if(player == '石头' && computer == arr[1] || player == '剪刀' && computer == arr[0] || player == '布' && computer == arr[2]){
				document.write("打成平手");
			}else{
				document.write("你输了");
			}
		</script>
	</body>
</html>
